using Godot;

public abstract partial class WeaponEntity : BaseSkill
{
    public int ID { get; set; }
    public string WeaponName => SkillName;
    public int HitRate => SkillData.ContainsKey("HitRate") ? SkillData["HitRate"].As<int>() : 0;
    public int AttackOcean => SkillData.ContainsKey("OCEAN") ? SkillData["OCEAN"].As<int>() : 0;
    public int AttackLand => SkillData.ContainsKey("LAND") ? SkillData["LAND"].As<int>() : 0;
    public int AttackAir => SkillData.ContainsKey("AIR") ? SkillData["AIR"].As<int>() : 0;
    public int AddHp => SkillData.ContainsKey("AddHp") ? SkillData["AddHp"].As<int>() : 0;

    public WeaponEntity(SkillModel model)
    {
        GameUtil.FastAssignment(model, this);
    }

    public bool CanAttackTarget(Robot robot)
    {
        var mt = robot.Entity.MoveType;
        // 并且武器能攻击指定类型的敌人
        if (mt == RobotMoveType.NONE || (mt == RobotMoveType.AIR && AttackAir > 0) || (mt == RobotMoveType.LAND && AttackLand > 0) || (mt == RobotMoveType.OCEAN && AttackOcean > 0))
        {
            return true;
        }
        return false;
    }
}